<% var isDefault =  @CoreUtils.isSysCodeDefault(); %>
<% layout('/layouts/default.html', {title: '商品管理', libs: ['dataGrid']}){ %>
<div class="main-content">
	<div class="box box-main">
		<div class="box-header">
			<div class="box-title">
				<i class="fa fa-list-alt"></i> ${text('商品管理')}
			</div>
			<div class="box-tools pull-right">
				<a href="#" class="btn btn-default" id="btnSearch" title="${text('查询')}"><i class="fa fa-filter"></i> ${text('查询')}</a>
				<% if(hasPermi('shop:goods:edit')){ %>
					<a href="${ctx}/shop/goods/form" class="btn btn-default btnTool" title="${text('新增商品')}"><i class="fa fa-plus"></i> ${text('新增')}</a>
				<% } %>
			</div>
		</div>
		<div class="box-body">
			<#form:form id="searchForm" model="${goods}" action="${ctx}/shop/goods/listData" method="post" class="form-inline "
					data-page-no="${parameter.pageNo}" data-page-size="${parameter.pageSize}" data-order-by="${parameter.orderBy}">
				<div class="form-group">
					<label class="control-label">${text('分类')}：</label>
					<div class="control-inline">
						<#form:input path="categoryCode" maxlength="11" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('本地分类')}：</label>
					<div class="control-inline">
						<#form:input path="extendCategoryCode" maxlength="11" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('商品编号')}：</label>
					<div class="control-inline">
						<#form:input path="goodsSn" maxlength="60" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('商品名称')}：</label>
					<div class="control-inline">
						<#form:input path="goodsName" maxlength="120" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('品牌名称')}：</label>
					<div class="control-inline">
						<#form:input path="brandId" maxlength="5" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('关键词')}：</label>
					<div class="control-inline">
						<#form:input path="keywords" maxlength="255" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('是否虚拟商品')}：</label>
					<div class="control-inline width-120">
						<#form:select path="isVirtual" dictType="sys_yes_no" blankOption="true" class="form-control"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('是否上架')}：</label>
					<div class="control-inline width-120">
						<#form:select path="isOnSale" dictType="sys_yes_no" blankOption="true" class="form-control"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('是否包邮')}：</label>
					<div class="control-inline width-120">
						<#form:select path="isFreeShipping" dictType="sys_yes_no" blankOption="true" class="form-control"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('上架时间')}：</label>
					<div class="control-inline">
						<#form:input path="onTime" maxlength="10" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('是否推荐')}：</label>
					<div class="control-inline width-120">
						<#form:select path="isRecommend" dictType="sys_yes_no" blankOption="true" class="form-control"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('是否新品')}：</label>
					<div class="control-inline width-120">
						<#form:select path="isNew" dictType="sys_yes_no" blankOption="true" class="form-control"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('是否热卖')}：</label>
					<div class="control-inline width-120">
						<#form:select path="isHot" dictType="sys_yes_no" blankOption="true" class="form-control"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('供货商')}：</label>
					<div class="control-inline">
						<#form:input path="suppliersId" maxlength="5" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('店铺名称')}：</label>
					<div class="control-inline">
						<#form:input path="shopId" maxlength="64" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('状态')}：</label>
					<div class="control-inline width-120">
						<#form:select path="status" dictType="sys_search_status" blankOption="true" class="form-control"/>
					</div>
				</div>
				<div class="form-group">
					<button type="submit" class="btn btn-primary btn-sm">${text('查询')}</button>
					<button type="reset" class="btn btn-default btn-sm">${text('重置')}</button>
				</div>
			</#form:form>
			<table id="dataGrid"></table>
			<div id="dataGridPage"></div>
		</div>
	</div>
</div>
<% } %>
<script>
// 初始化DataGrid对象
$('#dataGrid').dataGrid({
	searchForm: $("#searchForm"),
	columnModel: [
		{header:'${text('商品编号')}', name:'goodsSn', index:'a.goods_sn', width:150, align:"left"},
		{header:'${text('商品名称')}', name:'goodsName', index:'a.goods_name', width:150, align:"left"},
		{header:'${text('库存')}', name:'storeCount', index:'a.store_count', width:150, align:"center"},
		{header:'${text('市场价')}', name:'marketPrice', index:'a.market_price', width:150, align:"right", formatter: function(val, obj, row, act){
			return js.formatNumber(val, 2, false, ''); // 数值类型格式化 (原始数值, 小数位数, 是否千分位, 默认值，金额情况下设置0.00);
		}},
		{header:'${text('本店价')}', name:'shopPrice', index:'a.shop_price', width:150, align:"right", formatter: function(val, obj, row, act){
			return js.formatNumber(val, 2, false, ''); // 数值类型格式化 (原始数值, 小数位数, 是否千分位, 默认值，金额情况下设置0.00);
		}},
		{header:'${text('成本价')}', name:'costPrice', index:'a.cost_price', width:150, align:"right", formatter: function(val, obj, row, act){
			return js.formatNumber(val, 2, false, ''); // 数值类型格式化 (原始数值, 小数位数, 是否千分位, 默认值，金额情况下设置0.00);
		}},
		{header:'${text('关键词')}', name:'keywords', index:'a.keywords', width:150, align:"left"},
		{header:'${text('是否上架')}', name:'isOnSale', index:'a.is_on_sale', width:150, align:"center"},
		{header:'${text('上架时间')}', name:'onTime', index:'a.on_time', width:150, align:"center"},
		{header:'${text('商品排序')}', name:'goodsSort', index:'a.goods_sort', width:150, align:"center"},
		{header:'${text('是否推荐')}', name:'isRecommend', index:'a.is_recommend', width:150, align:"center"},
		{header:'${text('是否新品')}', name:'isNew', index:'a.is_new', width:150, align:"center"},
		{header:'${text('是否热卖')}', name:'isHot', index:'a.is_hot', width:150, align:"center"},
		{header:'${text('商品销量')}', name:'salesSum', index:'a.sales_sum', width:150, align:"center"},
		{header:'${text('店铺名称')}', name:'shopId', index:'a.shop_id', width:150, align:"left"},
		{header:'${text('状态')}', name:'status', index:'a.status', width:150, align:"center", formatter: function(val, obj, row, act){
			return js.getDictLabel(${@DictUtils.getDictListJson('sys_search_status')}, val, '${text('未知')}', true);
		}},
		{header:'${text('更新时间')}', name:'updateDate', index:'a.update_date', width:150, align:"center"},
		{header:'${text('操作')}', name:'actions', width:120, sortable:false, title:false, formatter: function(val, obj, row, act){
			var actions = [];
			<% if(hasPermi('shop:goods:edit')){ %>
				actions.push('<a href="${ctx}/shop/goods/form?goodsId='+row.goodsId+'" class="btnList" title="${text('编辑商品')}"><i class="fa fa-pencil"></i></a>&nbsp;');
				if (row.status == Global.STATUS_NORMAL){
					actions.push('<a href="${ctx}/shop/goods/disable?goodsId='+row.goodsId+'" class="btnList" title="${text('停用商品')}" data-confirm="${text('确认要停用该商品吗？')}"><i class="glyphicon glyphicon-ban-circle"></i></a>&nbsp;');
				}
				if (row.status == Global.STATUS_DISABLE){
					actions.push('<a href="${ctx}/shop/goods/enable?goodsId='+row.goodsId+'" class="btnList" title="${text('启用商品')}" data-confirm="${text('确认要启用该商品吗？')}"><i class="glyphicon glyphicon-ok-circle"></i></a>&nbsp;');
				}
				actions.push('<a href="${ctx}/shop/goods/delete?goodsId='+row.goodsId+'" class="btnList" title="${text('删除商品')}" data-confirm="${text('确认要删除该商品吗？')}"><i class="fa fa-trash-o"></i></a>&nbsp;');
			<% } %>
			return actions.join('');
		}}
	],
	// 加载成功后执行事件
	ajaxSuccess: function(data){
		
	}
});
</script>